package com.gxa.web_admin.controller;

import com.gxa.common.vo.JsonResult;
import com.gxa.common.vo.R;
import com.gxa.modules.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;

@RestController
@RequestMapping("/car")
public class CarController {

    @Autowired
    private CarService carService;

    /**
     * 查询车辆列表和条件查询
     * @param map
     * @return
     */
    @PostMapping("/findCar")
    public JsonResult findCar(@RequestBody HashMap map){
        return carService.findCar(map);
    }

    /**
     * 添加车辆
     * @param map
     * @return
     */
    @PostMapping("/addCar")
    public R addCar(@RequestBody HashMap map){
        return carService.addCar(map);
    }

    @GetMapping("/findCarById")
    public R findCarById(Integer car_id){
        return carService.findCayById(car_id);
    }

    /**
     * 编辑
     * @param map
     * @return
     */
    @PostMapping("/updateCar")
    public R updateCar(@RequestBody HashMap map){
        return carService.updateCar(map);
    }

    /**
     * 添加图片
     * @param file
     * @return
     */
    @PostMapping("/addImg")
    public R addImg(@RequestBody MultipartFile file){
        return carService.addImg(file);
    }
}
